package com.wuxiaolong.wechat.model;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.wuxiaolong.wechat.common.Constants;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import java.util.List;
import java.util.Map;

/**
 * Description:
 *
 * @author Leo
 * @date 2020-02-13
 */
@Setter
@Getter
@ToString
@NoArgsConstructor
@XStreamAlias("xml")
public class NewsMessage extends BaseMessage {

    @XStreamAlias("ArticleCount")
    private String articleCount;

    @XStreamAlias("Articles")
    private List<NewsItem> articles;

    public NewsMessage(Map<String,String> requestMap, List<NewsItem> articles){
        // 设置通用值
        super(requestMap);
        // 设置消息类型
        this.setMsgType(Constants.MSG_TYPE_NEWS);
        // 设置回复的消息内容
        this.articles = articles;
        this.articleCount =  articles==null ? "0" : String.valueOf(articles.size());
    }
}
